<extend name="Public/common" />
<block name="body">
	<div class="centerkk">
		<div class="centerkk-1">
			<ul>
				<li><span><img src="__IMG__/buytimebeijing1.png"/></span><span>使用条件:无</span></li>
				<li><span><img src="__IMG__/buytimebeijing4.png"/></span><span>到期时间:<input style="background:none;color:#fff;" value="<notempty name="member.vip" value="1">{$member['vip_end_time']}<else />0000-00-00</notempty>" /></span></li>
			</ul>
		</div>
		<div class="centerkk-2">
			<img src="__IMG__/buytimebeijing3.png"/>
		</div>
		<div class="centerkk-3">
			<input style="background:none;color:#fbe806;font-size:0.37rem;margin-right:0.5rem;width:100%;" value="<eq name="member.vip" value="1">{$member['vip_number']}</eq>" readonly="true" />
			<!--1234 4567 8912 2345 7890-->
		</div>
	</div>
	<div class="centermm">
		<div class="centermm-1">
			<p>会员卡说明</p>
		</div>
		<div class="centermm-2">
			<p id="restaurantDetails">{:getConfig('member_desc')}</p>
		</div>
	</div>
	<div class="footp">
		<span>到底了哦~</span>
	</div>
	<neq name="member.vip" value="1">
	<div class="abtn">
		<a id="payBtn">购买会员卡（{$vipPrice}元）</a>
	</div>
	</neq>
</block>
<block name="js">
<script type="text/javascript">
	var aBox = $('.abtn').find('a');
	aBox.css({'display':'block','line-height':aBox.height()+"px"});

	//点击支付
	$('#payBtn').click(function(){
		$.ajax({
			url: "{:C('SITE_URL')}wechat/index/submitVip",
			dataType: "json",
			data: {},
			type: "POST",
			beforeSend: function() { salert("订单支付中"); },
			success: function(data) {
				if(data.code == 0){
					callpay(data.data);
				} else {
					salert(data.msg);
				}
			},
//					complete: function() { },
			error: function() {
				salert("订单支付失败，请重新支付");
			}
		});
	});

	function jsApiCall(data){
		WeixinJSBridge.invoke(
				'getBrandWCPayRequest',
				data,
				function(res){
					//WeixinJSBridge.log(res.err_msg);
					//alert(res.err_code+res.err_desc+res.err_msg);
					if(res.err_msg == "get_brand_wcpay_request:ok"){
						window.location = "{:C('SITE_URL')}wechat/index/vip";
					} else {
						salert("支付取消，请重新支付");
					}
				}
		);
	}

	function callpay(data){
		if (typeof WeixinJSBridge == "undefined"){
			if( document.addEventListener ){
				document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
			}else if (document.attachEvent){
				document.attachEvent('WeixinJSBridgeReady', jsApiCall);
				document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
			}
		}else{
			jsApiCall(data);
		}
	}
</script>
</block>